package 乘积三元组;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int N = 7010, M = 200010;
    static int[] a = new int[N];
    static int[] s = new int[M];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        for (int cases = 1; cases <= T; cases++) {
            Arrays.fill(s, 0);
            int n = in.nextInt();
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            Arrays.sort(a, 0, n);
            long res = 0;
            int not_zero = 0;
            for (int i = n - 1; i > 0 && a[i] > 0; i--) {//枚举Ay
                not_zero++;
                for (int j = 0; j < i; j++) {// 枚举Ax
                    if ((long) a[i] * a[j] < M) {
                        res += s[a[i] * a[j]];
                    }
                }
                s[a[i]]++;
            }
            int zero = n - not_zero;
            //组合数：从zero个0中选3个
            res += (long) zero * (zero - 1) * (zero - 2) / 6;  //0 * 0 = 0

            //组合数：从zero个0中选两个，not_zero个非0中选一个
            res += (long) not_zero * zero * (zero - 1) / 2;    //0 * A = 0
            System.out.printf("Case #%d: %d\n", cases, res);
        }
    }
}
